<?php
namespace addons\cloudstorage\model;

use think\Model;

class CloudStorage extends Model
{
    protected $name = 'cloud_storage';
    
    protected $autoWriteTimestamp = true;
    
    protected $json = ['config'];
    
    protected $jsonAssoc = true;
    
    /**
     * 获取默认存储配置
     */
    public static function getDefault($type = null)
    {
        $query = self::where('is_default', 1)->where('status', 1);
        if ($type) {
            $query->where('type', $type);
        }
        return $query->find();
    }
    
    /**
     * 获取所有可用的存储配置
     */
    public static function getAllAvailable()
    {
        return self::where('status', 1)->select();
    }
}
?>
